import java.util.ArrayList;
import java.util.List;

//Department就是Composite，可以管理Major
public class Department extends OrganizationComponent{

    //存放专业
    List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

    //构造器
    public Department(String name, String des) {
        super(name, des);
    }

    //重写add方法
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }
    //重写remove方法
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    //输出Department包含的专业
    @Override
    protected void print() {
        System.out.println("-------"+getName()+"-------");
        //遍历
        for (OrganizationComponent organizationComponent:organizationComponents
             ) {
            organizationComponent.print();
        }
    }

}
